package com.jj.fallback;

import com.jj.client.UserClient;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class UserClientFallbackFactory implements FallbackFactory<UserClient> {

    private static final Logger LOG = LoggerFactory.getLogger(UserClientFallbackFactory.class);

    @Override
    public UserClient create(Throwable cause) {
        return new UserClient() {
            @Override
            public String getInfo(String name, int age) {
                LOG.error("发生异常，触发UserClientFallbackFactory中的托底数据："+cause);
                return "拖底数据";
            }
        };
    }
}
